package com.project.personalfundmanager.shared.models;

import com.extjs.gxt.ui.client.data.BaseModel;
import com.project.personalfundmanager.client.common.Const;
import com.project.personalfundmanager.client.common.ModelHelper;
import com.project.personalfundmanager.client.listeners.Displayable;
import com.project.personalfundmanager.shared.DAOs.TaxableIncomeDAO;

public class TaxableIncomeModel extends BaseModel implements Displayable
{

	private static final long serialVersionUID = 1L;

	public TaxableIncomeModel( TaxableIncomeDAO dao )
	{
		setBasicSalary( dao.getBasicSalary() );
		setConveyance( dao.getConveyance() );
		setHRA( dao.getHra() );
		setOtherIncome( dao.getOtherIncome() );
		setTotal( dao.getTotal() );
	}
	
	public static void copyToModel(TaxableIncomeModel fromModel, TaxableIncomeModel toModel)
	{
		toModel.setBasicSalary( fromModel.getBasicSalary() );
		toModel.setConveyance( fromModel.getConveyance() );
		toModel.setHRA( fromModel.getHRA());
		toModel.setOtherIncome( fromModel.getOtherIncome() );
		toModel.setTotal( fromModel.getTotal() );
	}

	public TaxableIncomeModel()
	{
		setDisplayString();
	}

	public void setDisplayString()
	{
		set( "displayString", "Total Income" );
	}

	public void setBasicSalary( Integer salary )
	{
		set( Const.BASIC_SALARY, salary );
	}

	public Integer getBasicSalary()
	{
		return ModelHelper.getNullSafeInt( get( Const.BASIC_SALARY) );
	}

	public void setConveyance( Integer Conveyance )
	{
		set( Const.CONVEYANCE, Conveyance );
	}

	public Integer getConveyance()
	{
		return ModelHelper.getNullSafeInt( get( Const.CONVEYANCE ) );
	}

	public void setHRA( Integer salary )
	{
		set( Const.HRA, salary );
	}

	public Integer getHRA()
	{
		return ModelHelper.getNullSafeInt( get( Const.HRA ) );
	}

	public void setOtherIncome( Integer salary )
	{
		set( Const.OTHER_INCOME, salary );
	}

	public Integer getOtherIncome()
	{
		return ModelHelper.getNullSafeInt( get( Const.OTHER_INCOME ) );
	}

	public void setTotal( Integer salary )
	{
		set( Const.TOTAL_INCOME, salary );
	}

	public Integer getTotal()
	{
		return ModelHelper.getNullSafeInt( get( Const.TOTAL_INCOME ) );
	}
}
